<template>
    <view>
		<!-- 顶部导航 -->
		<view v-if="goods != null" :class="'page_big '+(is_single_page == 1 ? ' single-page-top' : '')" :style="page_big_bottom">
			<!-- #ifdef APP-PLUS -->
			<!-- 右侧icon -->
			<view class="top-share-right-icon">
			    <uni-icons type="redo" size="20" color="#333" class="icon round cp" @tap="popup_share_event"></uni-icons>
			</view>
			<!-- #endif -->
			<!-- 相册 -->
			<view class="goods-photo bg-white oh pr" v-if="goods_photo.length > 0" :style="'height: ' + photo_height + ' !important;'">
				<!-- 相册内容 -->
				<swiper :indicator-dots="indicator_dots" :indicator-color="indicator_color" :indicator-active-color="indicator_active_color" :autoplay="autoplay" :circular="circular" class="swiper" :style="'height: ' + photo_height + ' !important;'">
					<block v-for="(item, index) in goods_photo" :key="index">
						<swiper-item>
							<image class="swiper-item wh-auto-xiangce" @tap="goods_photo_view_event" :data-index="index" :src="item.images" mode="heightFix" :style="'height: ' + photo_height + ' !important;'" />
						</swiper-item>
					</block>
				</swiper>
			</view>

			<view class="padding-main margin-main border-radius-main bg-white yx_goods_detail_price_box_2">
				<view class="goods-title-content goods-title-content2 oh">
					<!-- 价格 -->
					<view class="price-content price-content-pt">
						<view class="single-text">
							<text class="sales-price t1 dis-inline-block">{{currency_symbol}}</text>
							<text class="sales-price t3 dis-inline-block">{{goods.price}}</text>
						</view>
					</view>
				</view>
				
				<!-- 标题 -->
				<view class="goods-title-2" :style="'color:' + goods.title_color">{{goods.title}}</view>
			</view>

			<view class="padding-main margin-main border-radius-main bg-white yx_goods_detail_price_box_foot">
				<!-- 简述 -->
				<view v-if="(goods.simple_desc || null) != null" class="cr-gray margin-bottom-lg">{{goods.simple_desc}}</view>
				
				<!-- icon -->
				<view class="goods-icon-container margin-bottom-sm margin-bottom-lg">
					<view v-if="goods.type == 1" class="fl tc radius text-size-xs bg-white" style="border:1px solid #36abff;color:#36abff;">虚拟物品</view>
					<view v-else class="fl tc radius text-size-xs bg-white" style="border:1px solid #36abff;color:#36abff;">实物</view>
				</view>
				<view class="cl"></view>
	
				<!-- 基础总计数据 -->
				<view class="base-grid oh padding-top-sm padding-bottom-sm">
					<view class="fl tl">
						<text class="cr-gray">库存</text>
						<text class="cr-gray padding-left-sm">{{goods.inventory}}</text>
					</view>
					<!--<view class="fl tc">
						<text class="cr-gray">热度</text>
						<text class="cr-gray padding-left-sm">{{goods.access_count}}</text>
					</view>-->
					<view class="fr tr">
						<text class="cr-gray">销量</text>
						<text class="cr-gray padding-left-sm">{{goods.sales_count}}{{goods.inventory_unit}}</text>
					</view>
				</view>
				
				<!-- 智能工具-基础提示信息 -->
				<view class="plugins-intellectstools-base-bottom-container pr oh">
					<view class="item-title">兑换提示：</view>
					<view class="notice-cc cp single-text">
						请注意积分兑换的商品不支持退换货！
					</view>
				</view>
			</view>

			<!-- 商品详情 -->
			<view class="goods-detail margin-main border-radius-main bg-white yx_goods_detail_xiangqing">
				<view class="spacing-nav-title padding-horizontal-main">
					<text class="line"></text>
					<text class="text-wrapper">商品详情</text>
				</view>
				<view class="border-radius-main oh bg-white">
					<view class="oh bg-white">
						<block v-if="(common_is_goods_detail_show_photo == 1 && goods_photo.length > 0) || (common_app_is_use_mobile_detail == 0 && (goods.content_web || null) != null) || (common_app_is_use_mobile_detail == 1 && goods_content_app.length > 0)">
							<!-- 是否详情展示相册 -->
							<block v-if="common_is_goods_detail_show_photo == 1 && goods_photo.length > 0">
								<view v-for="(item, index) in goods_photo" :key="index" class="goods-detail-photo">
									<image v-if="(item.images || null) != null" @tap="goods_detail_images_view_event" :data-value="item.images" class="wh-auto dis-block" :src="item.images" mode="widthFix"></image>
								</view>
							</block>
							<!-- web详情 -->
							<view v-if="(goods.content_web || null) != null" class="padding-main web-html-content">
								<mp-html :content="goods.content_web" />
							</view>
						</block>
						<block v-else>
							<view class="cr-grey tc padding-top-xxl padding-bottom-xxl">暂无详情数据</view>
						</block>
					</view>
				</view>
			</view>
			
			<!-- 分享弹窗 -->
			<component-share-popup :diyTheme="diytheme" ref="share"></component-share-popup>
			<!-- 结尾 -->
			<component-bottom-line :propStatus="data_bottom_line_status"></component-bottom-line>

			<!-- 底部操作 -->
			<view class="goods-buy-nav wh-auto bg-white bottom-line-exclude">
			    <view class="shop fl tc" @click="shop_event">
			        <image :src="scorestore_static_url+'mini/goods-detail-home-icon.png'" mode="scaleToFill" />
			        <text class="dis-block cr-888">首页</text>
			    </view>
			    <view class="fr">
			        <button class="bg-main" type="default" @click="buy_submit_event" hover-class="none" :disabled="nav_submit_is_disabled">
			            {{ nav_submit_text }}
			        </button>
			    </view>
			</view>
	
			<!-- 购买弹层 -->
			<!-- 弹层 -->
			<component-popup :prop-show="popup_status" prop-position="bottom" @onclose="popup_close_event">
			    <view class="goods-popup bg-white bottom-line-exclude">
			        <view class="close fr oh">
			            <view class="fr" @click.stop.prevent="popup_close_event">
			                <icon type="clear" size="20" />
			            </view>
			        </view>
			        <!-- 规格基础信息 -->
			        <view class="goods-popup-base oh br-b">
			            <image :src="goods_spec_base_images" mode="scaleToFill" class="br" />
			            <view class="goods-popup-base-content">
			                <view class="goods-price">
			                    <view class="sales-price">{{ goods_spec_base_price }}积分</view>
			                </view>
			                <view class="inventory">
			                    <text class="cr-888">库存</text>
			                    <text class="cr-666">{{ goods_spec_base_inventory }}</text>
			                    <text class="cr-888">{{ goods.inventory_unit }}</text>
			                </view>
			            </view>
			        </view>
			
			        <view class="goods-popup-content">
			            <!-- 商品属性 -->
			            <view v-if="goods_specifications_choose.length > 0" class="goods-attr-choose">
			                <view class="item br-b" v-for="(item, key) in goods_specifications_choose" :key="item.key">
			                    <view class="title">{{ item.name }}</view>
			
			                    <view v-if="item.value.length > 0" class="spec">
			                        <block v-for="(items, keys) in item.value" :key="items.key">
			                            <button
			                                @click.stop.prevent="goods_specifications_event"
			                                :data-key="key"
			                                :data-keys="keys"
			                                type="default"
			                                size="mini"
			                                hover-class="none"
			                                :class="items.is_active + ' ' + items.is_dont + ' ' + items.is_disabled"
			                            >
			                                <image v-if="(items.images || null) != null" :src="items.images" mode="scaleToFill" />
			                                {{ items.name }}
			                            </button>
			                        </block>
			                    </view>
			                </view>
			            </view>
			
			            <!-- 购买数量 -->
			            <view class="goods-buy-number oh">
			                <view class="title fl">兑换数量</view>
			                <view class="number-content tc oh">
			                    <view @click="goods_buy_number_event" class="number-submit tc cr-888 fl" data-type="0">-</view>
			                    <input @blur="goods_buy_number_blur" class="tc cr-888 fl" type="number" :value="temp_buy_number" />
			                    <view @click="goods_buy_number_event" class="number-submit tc cr-888 fl" data-type="1">+</view>
			                </view>
			            </view>
			        </view>
			        <button class="goods-popup-submit bg-main" type="default" @click.stop.prevent="goods_buy_confirm_event" hover-class="none">确定</button>
			    </view>
			</component-popup>
		</view>
		
		<!-- 提示信息 -->
		<component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
	
		<!-- 无商品信息展示返回按钮 -->
		<view v-if="goods == null && data_list_loding_status != 1" class="tc margin-top-xxxl">
			<button type="default" class="fengcheche-main-bgcolor fengcheche-br-main cr-white round" size="mini" @tap="goods_error_event">返回</button>
		</view>
		
		<!-- #ifdef APP-PLUS -->
		<yk-authpup ref="authpup" type="top" @changeAuth="changeAuth" :permissionID="permissionID"></yk-authpup>
		<!-- #endif -->
    </view>
</template>

<script>
const app = getApp();
import componentPopup from '@/components/popup/popup';
import componentQuickNav from "@/components/quick-nav/quick-nav";
import componentBadge from '@/components/badge/badge';
import componentNoData from "@/components/no-data/no-data";
import componentBottomLine from "@/components/bottom-line/bottom-line";
import componentOnlineService from "@/components/online-service/online-service";
import componentSharePopup from "@/components/share-popup/share-popup";
// #ifdef APP-PLUS
import ykAuthpup from "@/components/yk-authpup/yk-authpup";
// #endif
var scorestore_static_url = app.globalData.get_static_url('scorestore', true);
var common_static_url = app.globalData.get_static_url('common');

var system_info = app.globalData.get_system_info() || {};
var win_width = parseInt(system_info.windowWidth || system_info.screenWidth || 0);
export default {
    components: {
		// #ifdef APP-PLUS
		ykAuthpup,
		// #endif
        componentPopup,
		componentQuickNav,
		componentBadge,
		componentNoData,
		componentBottomLine,
		componentOnlineService,
		componentSharePopup
    },
    data() {
        return {
			currency_symbol:'积分',
			scorestore_static_url:scorestore_static_url,
			common_static_url:common_static_url,
            indicator_dots: false,
            indicator_color: '',
            indicator_active_color: '',
            autoplay: true,
            circular: true,
            data_bottom_line_status: false,
            data_list_loding_status: 1,
            data_list_loding_msg: '',
            params: null,
            goods: null,
            goods_photo: [],
            goods_specifications_choose: [],
            goods_content_app: [],
            popup_status: false,
			// 是否单页预览
			is_single_page: app.globalData.is_current_single_page() || 0,
            goods_favor_text: '收藏',
            goods_favor_icon: '/static/images/goods-detail-favor-icon-0.png',
            temp_buy_number: 1,
            buy_event_type: 'buy',
            nav_submit_text: '立即兑换',
            nav_submit_is_disabled: true,
            goods_spec_base_price: 0,
            goods_spec_base_original_price: 0,
            goods_spec_base_inventory: 0,
            goods_spec_base_images: {},
            show_field_price_text: null,
            common_is_goods_detail_show_photo: 0,
            common_app_is_use_mobile_detail: 1,
            common_app_is_online_service: 0,
            temp_attribute_active: {},
            keys: [],
			share_info:{},
			photo_height: (win_width <= 0) ? '55vh' : app.globalData.window_width_handle(win_width) + 'px',
			page_big_bottom:'',
			diytheme: null,
			permissionID:''
        };
    },
    onLoad(params) {
        // 启动参数处理
        params = app.globalData.launch_params_handle(params);
        this.setData({
            params: params
        });
        this.init();
    },
    onShow() {
        app.globalData.page_event_onshow_handle();

        //app.globalData.show_share_menu();
    },
    // 下拉刷新
    onPullDownRefresh() {
        this.init();
    },
    // 自定义分享
    onShareAppMessage() {
        var user = app.globalData.get_user_cache_info() || null;
        var user_id = user != null && (user.id || null) != null ? user.id : 0;
        return {
            title: app.globalData.data.application_title + '-' + this.goods.title,
            desc: app.globalData.data.application_describe,
            path: '/pages/fcc/scorestore/detail/detail?goods_id=' + this.goods.id + '&referrer=' + user_id
        };
    },
    methods: {
        // 获取数据列表
        init() {
            // 数据初始化
            this.setData({
                temp_attribute_active: {}
            }); // 参数校验

            if ((this.params.goods_id || null) == null) {
                uni.stopPullDownRefresh();
                this.setData({
                    data_bottom_line_status: false,
                    data_list_loding_status: 2,
                    data_list_loding_msg: '商品ID有误'
                });
            } else {
                var self = this; // 加载loding

                uni.showLoading({
                    title: this.$t('common.loading_in_text'),
                });
                this.setData({
                    data_list_loding_status: 1
                });
                uni.request({
                    url: app.globalData.get_request_url('detail', 'index', 'scorestore'),
                    method: 'POST',
                    data: {
                        goods_id: this.params.goods_id
                    },
                    dataType: 'json',
                    success: (res) => {
                        uni.stopPullDownRefresh();
                        uni.hideLoading();

                        if (res.data.code == 0) {
                            var data = res.data.data;
                            console.log(res);
                            self.setData({
                                goods: data.goods,
                                indicator_dots: data.goods.photo.length > 1,
                                autoplay: data.goods.photo.length > 1,
                                goods_photo: data.goods.photo,
                                //goods_specifications_choose: data.goods.specifications.choose || [],
                                goods_content_app: data.goods.content_app,
                                temp_buy_number: data.goods.buy_min_number || 1,
                                //goods_favor_text: (data.goods.is_favor == 1) ? '已收藏' : '收藏',
                                //goods_favor_icon: '/images/goods-detail-favor-icon-' + data.goods.is_favor + '.png',
                                //nav_submit_text: ((data.common_order_is_booking || 0) == 0) ? '立即兑换' : '立即预约',
                                data_bottom_line_status: true,
                                data_list_loding_status: 3,
                                nav_submit_is_disabled: data.goods.is_shelves == 1 && data.goods.inventory > 0 ? false : true,
                                common_app_is_use_mobile_detail: data.common_app_is_use_mobile_detail || 0,
                                common_is_goods_detail_show_photo: data.common_is_goods_detail_show_photo || 0,
                                common_app_is_online_service: data.common_app_is_online_service || 0,
                                goods_spec_base_price: data.goods.price,
                                goods_spec_base_original_price: data.goods.original_price,
                                goods_spec_base_inventory: data.goods.inventory,
                                goods_spec_base_images: data.goods.images,
                                show_field_price_text: data.goods.show_field_price_text == '销售价' ? null : data.goods.show_field_price_text.replace(/<[^>]+>/g, '') || null,
								share_info: {
								    title: data.goods.seo_title || data.goods.title,
								    kds: data.goods.seo_keywords || data.goods.simple_desc,
								    desc: data.goods.seo_desc || data.goods.simple_desc,
								    path: '/pages/fcc/scorestore/detail/detail',
								    query: 'goods_id=' + data.goods.id,
								    img: data.goods.images,
								    video: data.goods.video
								}
                            }); // 不能选择规格处理

                            this.goods_specifications_choose_handle_dont(0);

                            if (data.goods.is_shelves != 1) {
                                this.setData({
                                    nav_submit_text: '商品已下架',
                                    nav_submit_is_disabled: true
                                });
                            } else {
                                if (data.goods.inventory <= 0) {
                                    this.setData({
                                        nav_submit_text: '商品卖光了',
                                        nav_submit_is_disabled: true
                                    });
                                }
                            }
							
							// 分享菜单处理
							app.globalData.page_share_handle(this.share_info);
							
							// 标题
							uni.setNavigationBarTitle({
							    title: data.goods.title
							});
                        } else {
                            self.setData({
                                data_bottom_line_status: false,
                                data_list_loding_status: 0,
                                data_list_loding_msg: res.data.msg
                            });
                        }
                    },
                    fail: () => {
                        uni.stopPullDownRefresh();
                        uni.hideLoading();
                        self.setData({
                            data_bottom_line_status: false,
                            data_list_loding_status: 2,
                            data_list_loding_msg: this.$t('common.internet_error_tips')
                        });
                        app.globalData.showToast(this.$t('common.internet_error_tips'));
                    }
                });
            }
        },
		
		// 分享开启弹层
		popup_share_event(e) {
			if ((this.$refs.share || null) != null) {
				this.$refs.share.init({
					status: true,
					share_info: this.share_info
				});
			}
		},

        // 不能选择规格处理
        goods_specifications_choose_handle_dont(key) {
            var temp_data = this.goods_specifications_choose || [];

            if (temp_data.length <= 0) {
                return false;
            } // 是否不能选择

            for (var i in temp_data) {
                for (var k in temp_data[i]['value']) {
                    if (i > key) {
                        temp_data[i]['value'][k]['is_dont'] = 'spec-dont-choose';
                        temp_data[i]['value'][k]['is_disabled'] = '';
                        temp_data[i]['value'][k]['is_active'] = '';
                    } // 当只有一个规格的时候

                    if (key == 0 && temp_data.length == 1) {
                        if ((temp_data[i]['value'][k]['is_only_level_one'] || null) != null && (temp_data[i]['value'][k]['inventory'] || 0) <= 0) {
                            temp_data[i]['value'][k]['is_disabled'] = 'spec-items-disabled';
                        } else {
                            temp_data[i]['value'][k]['is_disabled'] = '';
                        }
                    }
                }
            }

            this.setData({
                goods_specifications_choose: temp_data
            });
        },

        // 进入商品属性事件
        good_attribute_nav_event(e) {
            app.globalData.url_open('/pages/goods-attribute/goods-attribute?data=' + JSON.stringify(this.goods_attribute_show));
        },

        // 弹层关闭
        popup_close_event(e) {
            this.setData({
                popup_status: false
            });
        },

        // 进入积分商城首页
        shop_event(e) {
            app.globalData.url_open('/pages/fcc/scorestore/index/index');
        },

        // 加入购物车
        cart_submit_event(e) {
            this.setData({
                popup_status: true,
                buy_event_type: 'cart'
            });
        },

        // 立即购买
        buy_submit_event(e) {
            this.setData({
                popup_status: true,
                buy_event_type: 'buy'
            });
        },

        // 收藏事件
        goods_favor_event(e) {
            var user = app.globalData.get_user_cache_info(this, 'goods_favor_event', e); // 用户未绑定用户则转到登录页面

            if (user != false) {
                uni.showLoading({
                    title: '处理中...'
                });
                uni.request({
                    url: app.globalData.get_request_url('favor', 'index', 'scorestore'),
                    method: 'POST',
                    data: {
                        id: this.goods.id,
                        shopid: this.shopid
                    },
                    dataType: 'json',
                    success: (res) => {
                        uni.hideLoading();

                        if (res.data.code == 0) {
                            var status = this.goods.is_favor == 1 ? 0 : 1;
                            this.setData({
                                'goods.is_favor': status,
                                goods_favor_text: status == 1 ? '已收藏' : '收藏',
                                goods_favor_icon: '/images/goods-detail-favor-icon-' + status + '.png'
                            });
                            app.globalData.showToast(res.data.msg, 'success');
                        } else {
                            app.globalData.showToast(res.data.msg);
                        }
                    },
                    fail: () => {
                        uni.hideLoading();
                        app.globalData.showToast(this.$t('common.internet_error_tips'));
                    }
                });
            }
        },

        // 规格事件
        goods_specifications_event(e) {
            var key = e.currentTarget.dataset.key || 0;
            var keys = e.currentTarget.dataset.keys || 0;
            var temp_data = this.goods_specifications_choose;
            var temp_images = this.goods_spec_base_images; // 不能选择和禁止选择跳过

            if ((temp_data[key]['value'][keys]['is_dont'] || null) == null && (temp_data[key]['value'][keys]['is_disabled'] || null) == null) {
                // 规格选择
                for (var i in temp_data) {
                    for (var k in temp_data[i]['value']) {
                        if ((temp_data[i]['value'][k]['is_dont'] || null) == null && (temp_data[i]['value'][k]['is_disabled'] || null) == null) {
                            if (key == i) {
                                if (keys == k && (temp_data[i]['value'][k]['is_active'] || null) == null) {
                                    temp_data[i]['value'][k]['is_active'] = 'spec-active';

                                    if ((temp_data[i]['value'][k]['images'] || null) != null) {
                                        temp_images = temp_data[i]['value'][k]['images'];
                                    }
                                } else {
                                    temp_data[i]['value'][k]['is_active'] = '';
                                }
                            }
                        }
                    }
                }

                this.setData({
                    goods_specifications_choose: temp_data,
                    goods_spec_base_images: temp_images,
                    temp_buy_number: this.goods.buy_min_number || 1
                }); // 不能选择规格处理

                this.goods_specifications_choose_handle_dont(key); // 获取下一个规格类型
                //this.get_goods_specifications_type(key);
                // 获取规格详情
                //this.get_goods_specifications_detail();
            }
        },

        // 获取规格详情
        get_goods_specifications_detail() {
            // 是否全部选中
            var temp_data = this.goods_specifications_choose;
            var sku_count = temp_data.length;
            var active_count = 0; // 获取规格值

            var spec = [];

            for (var i in temp_data) {
                for (var k in temp_data[i]['value']) {
                    if ((temp_data[i]['value'][k]['is_active'] || null) != null) {
                        active_count++;
                        spec.push({
                            type: temp_data[i]['name'],
                            value: temp_data[i]['value'][k]['name']
                        });
                        break;
                    }
                }
            }

            if (spec.length <= 0 || active_count < sku_count) {
                this.setData({
                    goods_spec_base_price: this.goods.price,
                    goods_spec_base_original_price: this.goods.original_price,
                    goods_spec_base_inventory: this.goods.inventory
                });
                return false;
            } // 获取数据

            uni.request({
                url: app.globalData.get_request_url('specdetail', 'index', 'scorestore'),
                method: 'POST',
                data: {
                    id: this.goods.id,
                    spec: JSON.stringify(spec),
                    shopid: this.shopid
                },
                dataType: 'json',
                success: (res) => {
                    if (res.data.code == 0) {
                        this.setData({
                            goods_spec_base_price: res.data.data.price,
                            goods_spec_base_original_price: res.data.data.original_price,
                            goods_spec_base_inventory: res.data.data.inventory
                        });
                    } else {
                        app.globalData.showToast(res.data.msg);
                    }
                },
                fail: () => {
                    app.globalData.showToast(this.$t('common.internet_error_tips'));
                }
            });
        },

        // 数量输入事件
        goods_buy_number_blur(e) {
            var buy_number = parseInt(e.detail.value) || 1;
            this.setData({
                temp_buy_number: buy_number
            });
            this.goods_buy_number_func(buy_number);
        },

        // 数量操作事件
        goods_buy_number_event(e) {
            var type = parseInt(e.currentTarget.dataset.type) || 0;
            var temp_buy_number = parseInt(this.temp_buy_number);

            if (type == 0) {
                var buy_number = temp_buy_number - 1;
            } else {
                var buy_number = temp_buy_number + 1;
            }

            this.goods_buy_number_func(buy_number);
        },

        // 数量处理方法
        goods_buy_number_func(buy_number) {
            var buy_min_number = parseInt(this.goods.buy_min_number) || 1;
            var buy_max_number = parseInt(this.goods.buy_max_number) || 0;
            var inventory = parseInt(this.goods_spec_base_inventory);
            var inventory_unit = this.goods.inventory_unit;

            if (buy_number < buy_min_number) {
                buy_number = buy_min_number;

                if (buy_min_number > 1) {
                    app.globalData.showToast('起兑' + buy_min_number + inventory_unit);
                }
            }

            if (buy_max_number > 0 && buy_number > buy_max_number) {
                buy_number = buy_max_number;
                app.globalData.showToast('限兑' + buy_max_number + inventory_unit);
            }

            if (buy_number > inventory) {
                buy_number = inventory;
                app.globalData.showToast('库存数量' + inventory + inventory_unit);
            }

            this.setData({
                temp_buy_number: buy_number
            });
        },

        // 确认
        goods_buy_confirm_event(e) {
            var user = app.globalData.get_user_info(this, 'goods_buy_confirm_event');

            if (user != false) {
				// 属性
				var temp_data = this.goods_specifications_choose;
				var sku_count = temp_data.length;
				var active_count = 0;
				var spec = [];

				if (sku_count > 0) {
					for (var i in temp_data) {
						for (var k in temp_data[i]['value']) {
							if ((temp_data[i]['value'][k]['is_active'] || null) != null) {
								active_count++;
								spec.push({
									type: temp_data[i]['name'],
									value: temp_data[i]['value'][k]['name']
								});
							}
						}
					}

					if (active_count < sku_count) {
						app.globalData.showToast('请选择属性');
						return false;
					}
				} // 操作类型

				switch (this.buy_event_type) {
					case 'buy':
						// 进入订单确认页面
						var data = {
							buy_type: 'goods',
							goods_id: this.goods.id,
							stock: this.temp_buy_number,
							spec: JSON.stringify(spec)
						};
						app.globalData.url_open('/pages/fcc/scorestore/buy/buy?data=' + encodeURIComponent(JSON.stringify(data)));
						this.popup_close_event();
						break;

					default:
						app.globalData.showToast('操作事件类型有误');
				}
            }
        },

        // 详情图片查看
        goods_detail_images_view_event(e) {
            var value = e.currentTarget.dataset.value || null;

            if (value != null) {
				if(app.globalData.is_android())
				{
					var self = this;
					uni.previewImage({
					    current: value,
					    urls: [value],
						longPressActions: {
							itemList: [self.$t('fengcheche.fcctips.t9')],
							success: function(data) {
								uni.closePreviewImage();
								self.permissionID = 'WRITE_EXTERNAL_STORAGE';
								setTimeout(()=>{
									self.$refs['authpup'].open(value);
								},500);
							},
							fail: function(err) {
								console.log(err.errMsg);
							}
						}
					});
				}else{
					uni.previewImage({
					    current: value,
					    urls: [value],
					});
				}
            }
        },
		
		// #ifdef APP-PLUS
		//用户授权权限后的回调
		changeAuth(e){
			// 如果是头像查看的权限返回
			if(this.permissionID == 'WRITE_EXTERNAL_STORAGE')
			{
				app.globalData.save_image_by_url(e);
			}
		},
		// #endif

        // 商品相册图片查看
        goods_photo_view_event(e) {
            var index = e.currentTarget.dataset.index;
            var all = [];

            for (var i in this.goods_photo) {
                all.push(this.goods_photo[i]['images']);
            }
			if(app.globalData.is_android())
			{
				var self = this;
				uni.previewImage({
				    current: index,
				    urls: all,
					longPressActions: {
						itemList: [self.$t('fengcheche.fcctips.t9')],
						success: function(data) {
							uni.closePreviewImage();
							self.permissionID = 'WRITE_EXTERNAL_STORAGE';
							setTimeout(()=>{
								self.$refs['authpup'].open(all[index]);
							},500);
						},
						fail: function(err) {
							console.log(err.errMsg);
						}
					}
				});
			}else{
				uni.previewImage({
				    current: index,
				    urls: all
				});
			}
        }
    }
};
</script>
<style>
@import './detail.css';
</style>
